package com.general.app.wjgl.action;

import java.util.List;

import com.general.app.wjgl.dao.entity.Question;
import com.general.app.wjgl.service.IQuestionService;
import com.general.common.action.BaseAction;
import com.general.common.model.QueryModel;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.ValueStack;


/**
 * 问卷试题
 * @author Administrator
 *
 */
public class QuestionAction extends BaseAction implements ModelDriven<Question>{

	private static final long serialVersionUID = 2479306022215894203L;
	
	private Question model = new Question();
	private IQuestionService questionService;

	@Override
	public Question getModel() {
		return model;
	}

	public void setQuestionService(IQuestionService questionService) {
		this.questionService = questionService;
	}

	
	/**
	 * 试题列表查询
	 * @return
	 */
	public String getQuestionList(){
		QueryModel queryModel = model.getQueryModel();
		List<Question> questionList = questionService.getPagedList(model);
		queryModel.setItems(questionList);
		ValueStack vs = getValueStack();
		vs.set(DATA, queryModel);
		return DATA;
	}
	
	
	public String questionList(){
		return "questionList";
	}
	
	
	/**
	 * 按选择的ID查询试题
	 * @return
	 */
	public String getSelectQuestion(){
		
		String ids = getRequest().getParameter("ids");
		List<Question> questionList = questionService.getQuestionListByIds(ids);
		ValueStack vs = getValueStack();
		vs.set(DATA, questionList);
		return DATA;
	}
	
	
	
	
	/**
	 * 访问选择试题页面
	 * @return
	 */
	public String  toSelectQuestion(){
		
		return "selectQuestion";
	}
}
